package com.wlyuan.open;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.wlyuan.open.infrastructure.config.OpenApiCompanyProperties;
import com.wlyuan.open.infrastructure.config.OpenApiProperties;
import com.wlyuan.open.infrastructure.config.OpenQrCodeProperties;
import com.wlyuan.open.infrastructure.config.OpenSmsProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author yuanzheng
 */
@EnableScheduling
@EnableCaching
@EnableDubbo
@EnableConfigurationProperties({
        OpenApiProperties.class,
        OpenApiCompanyProperties.class,
        OpenSmsProperties.class,
        OpenQrCodeProperties.class
})
@SpringBootApplication
@EnableApolloConfig
@EnableTransactionManagement
@EnableFeignClients(basePackages = "com.wlyuan.open.remote.feign")
@Slf4j
public class OpenPlatformServiceApplication {
    public static void main(String[] args) {
        System.setProperty("dubbo.application.logger", "log4j2");
        SpringApplication.run(OpenPlatformServiceApplication.class, args);
        logger.info("启动成功");
    }

    @Bean
    @Primary
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
